package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.CommissionPresetGroup;
import com.ruoyi.system.mapper.CommissionPresetGroupMapper;
import com.ruoyi.system.service.ICommissionPresetGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * 分佣预设组Service业务层处理
 *
 * @author hjf
 * @date 2025-03-18
 */
@Service
public class CommissionPresetGroupServiceImpl implements ICommissionPresetGroupService {
    @Autowired
    private CommissionPresetGroupMapper commissionPresetGroupMapper;

    /**
     * 查询分佣预设组
     *
     * @param id 分佣预设组主键
     * @return 分佣预设组
     */
    @Override
    public CommissionPresetGroup selectCommissionPresetGroupById(Long id) {
        return commissionPresetGroupMapper.selectCommissionPresetGroupById(id);
    }

    /**
     * 查询分佣预设组列表
     *
     * @param commissionPresetGroup 分佣预设组
     * @return 分佣预设组
     */
    @Override
    public List<CommissionPresetGroup> selectCommissionPresetGroupList(CommissionPresetGroup commissionPresetGroup) {
        return commissionPresetGroupMapper.selectCommissionPresetGroupList(commissionPresetGroup);
    }


    @Override
    public HashMap<String, List<CommissionPresetGroup>> selectAll() {
        HashMap<String, List<CommissionPresetGroup>> map = new HashMap<>();
        List<CommissionPresetGroup> list = commissionPresetGroupMapper.selectAll();
        List<CommissionPresetGroup> z = new ArrayList<>();
        List<CommissionPresetGroup> f = new ArrayList<>();
        for (CommissionPresetGroup item : list) {
            if ("直播专用".equals(item.getTitle())) {
                z.add(item);
            } else if ("胡权".equals(item.getTitle())) {
                f.add(item);
            }
        }
        map.put("直播专用", z);
        map.put("胡权", f);
        return map;
    }

    /**
     * 新增分佣预设组
     *
     * @param commissionPresetGroup 分佣预设组
     * @return 结果
     */
    @Override
    public int insertCommissionPresetGroup(CommissionPresetGroup commissionPresetGroup) {
        return commissionPresetGroupMapper.insertCommissionPresetGroup(commissionPresetGroup);
    }

    /**
     * 修改分佣预设组
     *
     * @param commissionPresetGroup 分佣预设组
     * @return 结果
     */
    @Override
    public int updateCommissionPresetGroup(CommissionPresetGroup commissionPresetGroup) {
        return commissionPresetGroupMapper.updateCommissionPresetGroup(commissionPresetGroup);
    }

    /**
     * 批量删除分佣预设组
     *
     * @param ids 需要删除的分佣预设组主键
     * @return 结果
     */
    @Override
    public int deleteCommissionPresetGroupByIds(Long[] ids) {
        return commissionPresetGroupMapper.deleteCommissionPresetGroupByIds(ids);
    }

    /**
     * 删除分佣预设组信息
     *
     * @param id 分佣预设组主键
     * @return 结果
     */
    @Override
    public int deleteCommissionPresetGroupById(Long id) {
        return commissionPresetGroupMapper.deleteCommissionPresetGroupById(id);
    }
}
